<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>

    
        // 把数组中的每一个值自增2 

        function map(arr , cb) {
            var arr2 = arr.slice() ;
            for(var i = 0 ; i < arr2.length ; i++) {
                // arr[i] = arr[i] + 2 ;
                arr2[i] = cb(arr2[i]) ;
            }
            return arr2
        }

        var arr = [1,2,3] ;
        // map(arr , function(v) {
        //     return v + 2
        // }) ;
        // console.log(arr) ;


        function aa(v) {
            return v + 2
        }


        map(arr , aa) ;

    </script>
    
</body>
</html>